# -*- coding: utf-8 -*-
from __future__ import with_statement
import configparser
import re

path = "./Config/user_config.ini"
def load_cfg(n_path = path):
    n_cfg = configparser.ConfigParser()
    try:
        n_cfg.read(n_path)
        print("dd")
    except Exception as ex:
        print("config error  error!!")
        content = open(n_path).read()
        content = re.sub(r"\xfe\xff","", content)
        content = re.sub(r"\xff\xfe","", content)
        content = re.sub(r"\xef\xbb\xbf","", content)
        open(n_path, 'w').write(content)
        n_cfg.read(n_path)

    return n_cfg
#end def

def renew_cfg(n_cfg,n_path = path):
    n_cfg.write(open(n_path,"w"))
cfg = load_cfg(path)

if __name__ == "__main__":
    Config_path = "../Config/user_config.ini"
    load_cfg(Config_path)

